# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=cargo-generate
pkgver=0.20.0
pkgrel=0
pkgdesc="Use pre-existing git repositories as templates"
url="https://github.com/cargo-generate/cargo-generate"
license="MIT OR Apache-2.0"
arch="all !s390x" # fails to build nix crate
makedepends="cargo libgit2-dev openssl-dev cargo-auditable"
source="https://github.com/cargo-generate/cargo-generate/archive/v$pkgver/cargo-generate-$pkgver.tar.gz
	remove-cargo-husky.patch
	"
options="net" # fetch dependencies

prepare() {
	default_prepare

	# Rust target triple.
	local target=$(rustc -vV | sed -n 's/host: //p')

	# Build against system-provided libs
	mkdir -p .cargo
	cat >> .cargo/config.toml <<-EOF
		[target.$target]
		git2 = { rustc-link-lib = ["git2"] }
	EOF

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release --no-default-features
}

check() {
	cargo test --frozen --lib --no-default-features
}

package() {
	install -Dm755 target/release/$pkgname -t "$pkgdir"/usr/bin/
}

sha512sums="
ab6fa4b3519c4e35fef65eeb38caa226713fae5204950fc7b04fb38fa77d21045b7dee0defb2499df54dc17dd8780e3f580e13085de1dfdac87d1ac536c52afd  cargo-generate-0.20.0.tar.gz
50054cda7a9f22f89f1b447a197365737a73132ddd7c53f7a7e49eecf1bc1a6bb15dd7c97cf2cdda3b3468a94e6a9d8f0ce8910c972558eb09d16424667fdc31  remove-cargo-husky.patch
"
